Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client refactor #658

Merged
merged 10 commits into from
Oct 4, 2023
Merged

Client refactor #658

merged 10 commits into from
Oct 4, 2023

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Oct 3, 2023

  • Remove Func from MustDoFunc and DoFunc. They were called that to differentiate from the old-style Do and MustDo which are no more.
  • Move sync functions to a new file.
  • Move registration/login functions to a new file.
  • Move /internal/client to /client.
  • Signal unsafe functions.
  • Add more helper functions where their usage is proven in tests.
  • Use TestLike, an interface to represent testing.T to allow the client to be used outside of tests e.g benchmarks.

Slightly not client related:

  • Add federation.Event instead of abusing b.Event for creating events over federation. Makes this much clearer and fixes Add client.Event #381

Fixes #526 , #381

Partly addresses #226

- Remove `Func` from `MustDoFunc` and `DoFunc`. They were called that
  to differentiate from the old-style `Do` and `MustDo` which are no more.
- Move sync functions to a new file.
- Move registration/login functions to a new file.
- Move `/internal/client` to `/client`.
@kegsay kegsay requested review from a team as code owners October 3, 2023 12:34
@kegsay kegsay marked this pull request as draft October 3, 2023 12:34
@kegsay kegsay changed the title WIP: Client refactor Client refactor Oct 4, 2023
@kegsay kegsay marked this pull request as ready for review October 4, 2023 09:09
Copy link
Contributor

@S7evinK S7evinK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from comments, LGTM

client/auth.go Outdated Show resolved Hide resolved
tests/csapi/sync_archive_test.go Show resolved Hide resolved
tests/csapi/sync_archive_test.go Show resolved Hide resolved
// Unsafe_SendEventUnsynced sends `e` into the room. This function is UNSAFE as it does not wait
// for the event to be fully processed. This can cause flakey tests. Prefer `SendEventSynced`.
// Returns the event ID of the sent event.
func (c *CSAPI) Unsafe_SendEventUnsynced(t TestLike, roomID string, e b.Event) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (c *CSAPI) Unsafe_SendEventUnsynced(t TestLike, roomID string, e b.Event) string {
func (c *CSAPI) UnsafeSendEventUnsynced(t TestLike, roomID string, e b.Event) string {

Maybe? (same for the others)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to keep the _ to make it very clear that it's UNSAFE_SomeFuncName`, rather than just the function happens to have "unsafe" in the name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should jump out at the reader as being dodgey is my point.

@kegsay kegsay requested a review from DMRobertson October 4, 2023 10:45
client/client.go Outdated Show resolved Hide resolved
client/client.go Show resolved Hide resolved
client/client.go Outdated Show resolved Hide resolved
client/auth.go Show resolved Hide resolved
Copy link
Contributor

@DMRobertson DMRobertson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(otherwise, no objections)

@kegsay kegsay merged commit 67a1cce into main Oct 4, 2023
4 checks passed
@kegsay kegsay deleted the kegan/client branch October 4, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split up internal/client/client.go Add client.Event
3 participants